import collections
class Solution(object):
    def maxEqualRowsAfterFlips(self, matrix):
        m = len(matrix)
        n = len(matrix[0])
        for i in range(m):
            if matrix[i][0] == 1:
                for j in range(n):
                    matrix[i][j] = 1 - matrix[i][j]
        d = collections.defaultdict(int)
        for i in range(m):
            d[tuple(matrix[i])] += 1
        return max(d.values())


        